﻿using System;

namespace enyo
{
    [NonScript]
    public class WebServiceMethod
    {
        public static implicit operator WebServiceMethod(string str)
        {
            return null;
        }

        private WebServiceMethod() { }

        [EvalAtCompile]
        public const string GET = "GET";

        [EvalAtCompile]
        public const string POST = "POST";

        [EvalAtCompile]
        public const string PUT = "PUT";

        [EvalAtCompile]
        public const string DELETE = "DELETE";
    }

    [NonScript]
    public class WebServiceDataType
    {
        public static implicit operator WebServiceDataType(string str)
        {
            return null;
        }

        private WebServiceDataType() { }

        [EvalAtCompile]
        public const string JSON = "json";

        [EvalAtCompile]
        public const string Text = "text";

        [EvalAtCompile]
        public const string Xml = "xml";
    }

    //TODO:WebServiceRequest. service have corresponding request.
    public class WebService : Service
    {
        /// <summary>
        /// The URL for the service. This can be a relative URL if used to fetch resources bundled with the application.
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// The HTTP method to use for the request. Defaults to GET. 
        /// </summary>
        public WebServiceMethod Method { get; set; }

        /// <summary>
        /// How the response will be handled. 
        /// </summary>        
        public WebServiceDataType HandleAs { get; set; }

        /// <summary>
        /// The Content-Type header for the request as a String.
        /// </summary>
        public string ContentType { get; set; }

        /// <summary>
        /// If true, makes a synchronous (blocking) call, if supported.
        /// Synchronous requests are not supported on HP webOS.
        /// </summary>
        public bool Sync { get; set; }

        /// <summary>
        /// Optional additional request headers as a JS object, e.g., { "X-My-Header": "My Value", "Mood": "Happy" }, or null.
        /// </summary>
        public object/*TODO:type?*/ Headers { get; set; }

        /// <summary>
        /// The optional user name to use for authentication purposes.
        /// </summary>
        public string Username { get; set; }

        /// <summary>
        /// The optional password to use for authentication purposes.
        /// </summary>
        public string Password { get; set; }
    }
}
